package com.czk.model.iterator.practice;

import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;

/**
 * @Author:ChenZhangKun
 * @Date: 2020/6/17 22:46
 */
public class MarketDepartment implements Company {
    // 迭代的方式 集合
    private List<Person> list;
    // 迭代部门名称
    @Override
    public String getName() {
        return "市场部";
    }
    // 添加到集合中
    @Override
    public void addPerson(Person person) {
        list.add(person);
    }
    // 返回对应的迭代器
    @Override
    public Iterator iterator() {
        return new MarketDevelopmentIterator(new MarketDepartment());
    }
    // 初始化集合，具体可根据自己的逻辑来实现
    public MarketDepartment() {
        list=new ArrayList<>(10);
        addPerson(new Person("陈培英",25));
        addPerson(new Person("宁中琼",25));
        addPerson(new Person("成秋月",23));
        addPerson(new Person("胡容",27));
        addPerson(new Person("梁潇潇",26));
    }

    public List<Person> getList() {
        return list;
    }
}
